package com.dongdongshop.controller;

import com.dongdongshop.constant.HttpResultEnum;
import com.dongdongshop.data.DataResult;
import com.dongdongshop.pojo.content.TbContent;
import com.dongdongshop.service.content.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author Eayon
 * @Date 2020/4/3 14:33
 */
@RestController
@RequestMapping("content")
public class ContentController {

    @Autowired
    private ContentService contentService;


    /**
     * 按照广告分类查找分类下审核通过的广告信息
     * @param categoryId
     * @return
     */
    @GetMapping("/findByCategoryId/{categoryId}")
    public DataResult findByCategoryId(@PathVariable("categoryId")Long categoryId){
        List<TbContent> contents = contentService.findByCategoryId(categoryId);
        return new DataResult(HttpResultEnum.SUCCESS.getCode(),HttpResultEnum.SUCCESS.getMessage(),contents);
    }
}
